package com.cliave.ttweb.vo;

import com.cliave.ttweb.constant.DishConstant.DishContant;

import java.util.HashMap;
import java.util.Map;

public class DishResult {
    private Integer code;
    private String massage;
    private boolean success;
    private Map<String,Object> data = new HashMap<String, Object>();

    public static DishResult ok(){
        DishResult result = new DishResult();
        result.setSuccess(true);
        result.setCode(DishContant.SUCCESS);
        result.setMassage("成功");
        return result;
    }
    public static DishResult error(String massage){
        DishResult result = new DishResult();
        result.setSuccess(false);
        result.setCode(DishContant.ERROR);
        result.setMassage(massage);
        return result;
    }
    public DishResult data (String key,Object value){
    //往DishResult里面的Map集合添加数据
        this.data.put(key, value);
        return this;
    }
    //方法的重载
    public DishResult data(Map<String,Object> map){
        this.setData(map);
        return this;
    }
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "DishResult{" +
                "code=" + code +
                ", massage='" + massage + '\'' +
                ", success=" + success +
                ", data=" + data +
                '}';
    }
}
